package com.apes.fn.business.fixedLoss.modle;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program:
 * @description: 定损报表
 * @author: lws
 * @create: 2022/10/17 9:58
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = LossQuotationReport.CONST_TABLE_NAME)
public class LossQuotationReport extends Model {
    public final static String CONST_TABLE_NAME = "ser_loss_quotation_report";

    @Id
    @Column(name = "id", nullable = false, length = 8)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "定损报表编码")
    @Comment("定损报表编码")
    private String id;

    @JSONField(format = DateUtil.SHOW_DATE_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "statistic_Date")
    @Comment("统计日期")
    private Date statisticDate;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "business_Staff", referencedColumnName = "id")
    @Comment("商务员工")
    private PartyRole businessStaff;

    @Column(name = "trace_arrival", columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("总跟踪到店数")
    private double countTraceArrival = 0;

    @Column(name = "insurance_member", columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("车险会员报案总数")
    private double countInsuranceMember = 0;

    @Column(name = "not_insurance_member", columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("非车险会员推送总数")
    private double countNotInsuranceMember = 0;

    @Column(name = "collaboration_insurance", columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("门店接车合作保险公司总数")
    private double countCollaborationInsurance = 0;

    @Column(name = "not_collaboration_insurance", columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("门店接车非合作保险总数")
    private double countNotCollaborationInsurance = 0;

    @Column(name = "survey_arrived", columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("代勘到店总数")
    private double countSurveyArrived = 0;

    @Column(name = "red_bull", columnDefinition = ApesConst.FIELD_QTY_16_4_0)
    @Comment("红牛案件到店总数")
    private double countRedBull = 0;

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "lossQuotationReport")
    private List<LossQuotationReportItem> lossQuotationReportItems = new ArrayList<>();
}
